home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------
- // DropShadowWithPath.cs ⌐ 2001 by Charles Petzold
- //-------------------------------------------------
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
-
- class DropShadowWithPath: FontMenuForm
- {
- const int iOffset = 10; // Aproximadamente 1/10 de pulgada (Exactamente en la impresora)
-
- public new static void Main()
- {
- Application.Run(new DropShadowWithPath());
- }
- public DropShadowWithPath()
- {
- Text = "Sombreado con trazado";
- Width *= 2;
- strText = "Sombra";
- font = new Font("Times New Roman", 108);
- }
- protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
- {
- GraphicsPath path = new GraphicsPath();
- float fFontSize = PointsToPageUnits(grfx, font);
-
- // Obtener las coordenadas para una cadena centrada.
-
- SizeF sizef = grfx.MeasureString(strText, font);
- PointF ptf = new PointF((cx - sizef.Width) / 2,
- (cy - sizef.Height) / 2);
-
- // A±adir el texto al trazado.
-
- path.AddString(strText, font.FontFamily, (int) font.Style,
- fFontSize, ptf, new StringFormat());
-
- // Borrar, llenar, traducur, llenar y dibujar.
-
- grfx.Clear(Color.White);
- grfx.FillPath(Brushes.Black, path);
- path.Transform(new Matrix(1, 0, 0, 1, -10, -10));
- grfx.FillPath(Brushes.White, path);
- grfx.DrawPath(Pens.Black, path);
- }
- }
-